<template>
  <div class="info-panel">
    <div class="info-content">
      <div class="info-item">
        <span class="info-label">成果名称：</span>
        <span class="info-value">{{ info.title || '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">本人排名：</span>
        <span class="info-value">{{ info.authorRank !== null ? info.authorRank : '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">获得时间：</span>
        <span class="info-value">{{ formatObtainTime(info.obtainTime) || '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">共同作者：</span>
        <span class="info-value">
          {{ info.authorInfo && info.authorInfo.length > 0
            ? info.authorInfo.map(author => author.name || author.id).join('、')
            : '暂无' }}
        </span>
      </div>
      <div class="info-item">
        <span class="info-label">成果归属：</span>
        <span class="info-value">{{ info.remarks || '暂无' }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  info: {
    type: Object,
    default: () => ({})
  }
})

// 格式化获得时间
const formatObtainTime = (time) => {
  if (!time) return null;

  try {
    const date = new Date(time);
    if (isNaN(date.getTime())) return null;

    // 格式化为YYYY年MM月DD日
    return date.toLocaleDateString('zh-CN', {
      year: 'numeric',
      month: '2-digit',
      day: '2-digit'
    }).replace(/\//g, '年').replace(/$/, '日');
  } catch (e) {
    console.error('时间格式化错误:', e);
    return null;
  }
}
</script>

<style scoped>
/* 原有样式保持不变 */
.info-panel {
  height: 100%;
}

.info-content {
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.info-item {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  color: #9aa0a6;
  font-weight: 500;
}

.info-value {
  font-size: 13px;
  color: #e8eaed;
  word-break: break-all;
  line-height: 1.4;
}

.info-content::-webkit-scrollbar {
  width: 8px;
}

.info-content::-webkit-scrollbar-track {
  background: #323639;
}

.info-content::-webkit-scrollbar-thumb {
  background: #5f6368;
  border-radius: 4px;
}

.info-content::-webkit-scrollbar-thumb:hover {
  background: #80868b;
}
</style>
